<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <script src="./jquery-3.4.1.min.js"></script>
  <script>
    // $.get().done()
    // $.post().done(fn).fail(fn).always(fn)

    $.ajax({
      url: "https://api.ymduo.com/Home/FootNews/lists",
      type: "post"
    }).done(function (res) {//success
      console.log(res)
    }).fail(function () {//error
      console.log("失败执行函数")
    }).always(function () {//complete
      console.log("总是执行的函数")
    })
    // $.when 请求多个ajax对象
    // $.when(ajax1,ajax2).done(function(res){

    // })
    $.when($.ajax({
      url: "https://api.ymduo.com/Home/FootNews/lists",
      type: "post"
    }), $.ajax({
      url: "https://api.ymduo.com/Home/Cart/cartnum",
      type: "post",
      data: { uid: 956519 }
    })).done(function (res1, res2) {
      console.log(res1) //res1第一个ajax请求的数据
      console.log(res2)//res2 第二个ajax请求的数据
    })

  </script>
</body>

</html>